/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
using VMukti.DataAccess;
using VMukti.Common;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using VMukti.Business.CommonDataContracts;
using VMuktiAPI;

namespace VMukti.Business
{
    public class ClsRoleCollection : ClsBaseCollection<ClsRole>
    {
        public static ClsRoleCollection GetAll()
        {
            ClsRoleCollection obj = new ClsRoleCollection();
            if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp)
            {
                try
                {
                    obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select * from vRoles;").dsInfo);
                }
                catch (System.ServiceModel.EndpointNotFoundException e)
                {
                    e.Data.Add("My Key", "GetAll()--:--ClsRoleCollection.cs--:--" + e.Message + " :--:--");
                    ClsException.LogError(e);
                    ClsException.WriteToErrorLogFile(e);
                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                    obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select * from vRoles;").dsInfo);
                }
                catch (System.ServiceModel.CommunicationException e)
                {
                    e.Data.Add("My Key", "GetAll()--:--ClsRoleCollection.cs--:--" + e.Message + " :--:--");
                    ClsException.LogError(e);
                    ClsException.WriteToErrorLogFile(e);
                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                     obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select * from vRoles;").dsInfo);
                }
            }
            else
            {
                obj.MapObjects(new ClsRoleDataService().Role_GetAll());
            }
            return obj;
        }

    }
}
